const state = { 
  list: [],
  page: {},
  companyList: [],
  departmentList: []
}

const actions = {
  saveList: ({ commit }, payload) => {
    commit('SAVELIST', payload)
  },
  saveCompanyList: ({ commit }, payload) => {
    commit('SAVECOMPANYLIST', payload)
  },
  saveDepartmentList: ({ commit }, payload) => {
    commit('SAVDEPARTMENTLIST', payload)
  }
}

const mutations = {
  SAVELIST: (state, payload) => {
    state.list = payload.result
    state.page = {
      number: payload.number || 1,
      total: payload.resultNum,
      size: 10
    }
  },
  SAVECOMPANYLIST: (state, payload) => {
    state.companyList = payload.result || []
  },
  SAVDEPARTMENTLIST: (state, payload) => {
    state.departmentList = payload.result || []
  },
}

export default {
  state,
  actions,
  mutations
}